package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.PhotoAlbum;
import com.miku.blog.domain.dto.PhotoAlbumDTO;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.PhotoAlbumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-06-14 0:29
 */
@Api(tags = "后台管理系统{相册}")
@RequestMapping("/admin")
@RestController
public class PhotoAlbumsController {

    @Autowired
    private PhotoAlbumService photoAlbumService;


    @SystemLog(notes = "获取相册列表{后台管理系统}")
    @ApiOperation(value = "获取相册列表接口", notes = "根据条件 获取相册列表")
    @GetMapping("/photos/albums")
    public ResponseResult getPhotoAlbums(@RequestParam("current") Integer current,
                                         @RequestParam("size") Integer size,
                                         @RequestParam(value = "keywords",required = false) String keywords,
                                         @RequestParam(value = "status",required = false) Integer status){
        return photoAlbumService.getPhotoAlbums(current,size,keywords,status);
    }



    @SystemLog(notes = "获取相册信息{后台管理系统}")
    @ApiOperation(value = "获取相册信息接口", notes = "根据相册ID 获取相册信息")
    @GetMapping("/photos/albums/info/{albumId}")
    public ResponseResult getPhotoAlbumIdInfo(@PathVariable("albumId") Integer albumId){
        return photoAlbumService.getPhotoAlbumIdInfo(albumId);
    }

    @SystemLog(notes = "获取相册信息列表{后台管理系统}")
    @ApiOperation(value = "获取相册信息列表接口")
    @GetMapping("/photos/albums/info")
    public ResponseResult getPhotoAlbumsInfo(){
        return photoAlbumService.getPhotoAlbumsInfo();
    }


    @SystemLog(notes = "添加或修改相册{文章发布分类选项}{后台管理系统}")
    @ApiOperation(value = "添加或修改相册接口")
    @PostMapping("/photos/albums")
    public ResponseResult addPhotoAlbum(@RequestBody PhotoAlbum photoAlbum){
        return photoAlbumService.addPhotoAlbum(photoAlbum);
    }


    @SystemLog(notes = "移动图片至对应相册{文章发布分类选项}{后台管理系统}")
    @ApiOperation(value = "移动图片至对应相册接口", notes = "根据图片ID、url 与相册ID 移动图片至对应相册")
    @PutMapping("/photos/album")
    public ResponseResult movePhoto(@RequestBody PhotoAlbumDTO photoAlbumDTO){
        return photoAlbumService.movePhoto(photoAlbumDTO);
    }

    @SystemLog(notes = "删除相册{后台管理系统}")
    @ApiOperation(value = "删除相册接口")
    @DeleteMapping("/photos/albums/{albumId}")
    public ResponseResult delAlbums(@PathVariable("albumId") Integer albumId){
        return photoAlbumService.delAlbums(albumId);
    }


}
